﻿﻿@model Zor_Web.Models.Base.V_Zor_Building
@using Webdiyer.WebControls.Mvc;
@using Zor_Tools;
@{
    Layout = null;
}
<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>楼宇信息列表</title>
    <link href="~/Content/LayerUI/src/css/layui.css" rel="stylesheet" />
    <link href="~/Content/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
    <link href="~/Content/Styles/zor.css" rel="stylesheet" />
    <!-- 框架必要 -->
    <script src="~/Content/Scripts/jquery/jquery-1.9.1.min.js"></script>
    <script src="~/Content/Scripts/learunui-framework.js"></script>
    <script src="~/Content/Scripts/Zor_AJax.js"></script>
    <!-- 消息提示 -->
    <script language='javascript' src='~/Content/layer/layer.js'></script>
    <!-- 上传 -->
    <script src="~/Content/Scripts/webuploader/webuploader.min.js"></script>
    <script src="~/Content/Scripts/uploader.js"></script>
    <!-- 表单验证 -->
    <script src="~/Content/Scripts/JValidator.js"></script>
</head>
<body class="gray-bg">
    <div class="layui-tab layui-tab-brief main-tab-container ">
        <div class="col-sm-12 ct-padding">
            <div class="col-sm-9 ct-padding">
                <button id="btnAdd" class="layui-btn layui-btn layui-btn-small"><span class="glyphicon glyphicon-plus"></span> 新增</button>
                <button id="btnUpdate" class="layui-btn layui-btn-warm  layui-btn-small"><span class="glyphicon glyphicon-pencil"></span> 编辑</button>
                <button id="btnDelete" class="layui-btn layui-btn-danger  layui-btn-small"><span class="glyphicon glyphicon-trash"></span> 删除</button>
                <button id="btnSearch" class="layui-btn layui-btn-normal layui-btn-small"><span class="glyphicon glyphicon-search"></span> 查询</button>
                <button id="btnMessage" class="layui-btn layui-btn-orchid  layui-btn-small"><span class="glyphicon glyphicon-list-alt"></span> 详情</button>
                <button id="btnExport" class="layui-btn layui-btn-springgreen  layui-btn-small"><span class="glyphicon glyphicon-share"></span> 导出</button>
                <button id="btnReplace" class="layui-btn layui-btn-blue layui-btn-small"><span class="glyphicon glyphicon-refresh"></span> 刷新</button>
            </div>
        </div>
        <div class="col-sm-12  layui-tab-content">
            <div class="mail-box" style="overflow-x:scroll;white-space:nowrap;">
                <table class="layui-table" lay-skin="line">
                    <thead>
                        <tr>
                            <th hidden></th>
                            <th></th>
                            <th hidden>所属社区</th>
                            <th hidden>建筑结构</th>
                            <th hidden>建筑年代</th>
                            <th>楼宇名称</th>
                            <th>地上层数</th>
                            <th>地下层数</th>
                            <th>经度</th>
                            <th>纬度</th>
                            <th>管理员姓名</th>
                            <th>管理员性别</th>
                            <th>管理员身份证号</th>
                            <th>管理员电话</th>
                            <th>创建时间</th>
                        </tr>
                    </thead>
                    <tbody id="accordion">
                    @foreach (var item in Model.PageData)
                    {
                        if (@item.Bd_Ground == null && @item.Bd_Longitude == null && @item.Bd_Latitude == null)
                    {
                    <tr>
                        <td hidden>@item.Bd_Id</td>
                        <td><input type="radio" name="chk" value="@item.Bd_Id" /></td>
                        <td hidden>@item.Dt_Id</td>
                        <td hidden>@item.Bd_Structure</td>
                        <td hidden>@item.Bd_Years</td>
                        <td> <span class='label label-warning pull-center'>请将（@item.Bd_Name）信息补充完整</span></td>
                        <td>@item.Bd_Ground</td>
                        <td>@item.Bd_Underground</td>
                        @if (@item.Bd_Longitude == null)
                        {
                           <td>@item.Bd_Longitude</td>    
                        }
                        else
                        {
                            <td>0</td> 
                        }
                        @if (@item.Bd_Latitude == null)
                        {
                            <td>@item.Bd_Latitude</td>
                        }
                        else
                        {
                            <td>0</td>
                        }                   
                        <td>@item.Bd_Aname</td>
                        <td>@item.Sex</td>
                        <td>@item.Bd_IDNumber</td>
                        <td>@item.Bd_Telephone</td>
                        <td>@TimeHelper.TimeStampToDateTime(item.Bd_CreateDate.ToString(), TimeHelper.ToTimeType.link_ymd)</td>
                        <td hidden>@item.Bd_Sex</td>
                        <td hidden>@item.Dt_Name</td>
                    </tr>
                        }
                        else {
                    <tr>
                        <td hidden>@item.Bd_Id</td>
                        <td><input type="radio" name="chk" value="@item.Bd_Id" /></td>
                        <td hidden>@item.Dt_Id</td>
                        <td hidden>@item.Bd_Structure</td>
                        <td hidden>@item.Bd_Years</td>
                        <td>@item.Bd_Name</td>
                        <td>@item.Bd_Ground</td>
                        <td>@item.Bd_Underground</td>
                        @if (@item.Bd_Longitude == null)
                        {
                            <td>@item.Bd_Longitude</td>
                        }
                        else
                        {
                            <td>0</td>
                        }
                        @if (@item.Bd_Latitude == null)
                        {
                            <td>@item.Bd_Latitude</td>
                        }
                        else
                        {
                            <td>0</td>
                        }                   
                        <td>@item.Bd_Aname</td>
                        <td>@item.Sex</td>
                        <td>@item.Bd_IDNumber</td>
                        <td>@item.Bd_Telephone</td>
                        <td>@TimeHelper.TimeStampToDateTime(item.Bd_CreateDate.ToString(), TimeHelper.ToTimeType.link_ymd)</td>
                        <td hidden>@item.Bd_Sex</td>
                        <td hidden>@item.Dt_Name</td>
                    </tr>
                    }
               }
                    </tbody>
                </table>

                <div class="col-sm-12">
                    <div class="col-sm-10">
                        @Html.Pager(Model.PageData, new PagerOptions { PageIndexParameterName = "index", ContainerTagName = "ul", PrevPageText = "上页", NextPageText = "下页", FirstPageText = "首页", LastPageText = "尾页", CssClass = "pagination", PagerItemsSeperator = "", CurrentPagerItemWrapperFormatString = "<li class=\"active\"><a href=\"#\">{0}</a></li>", PagerItemWrapperFormatString = "<li>{0}</li>" }, new { id = "bootstrappager", @class = "pagination" })
                    </div>
                    <div class="col-sm-2 to-righjt">
                        共 @Model.PageData.TotalItemCount 条记录，页 @Model.PageData.CurrentPageIndex/@Model.PageData.TotalPageCount
                    </div>
                </div>
            </div>
        </div>
        <!-- 模态 -->
        <div id="myModal" hidden data-backdrop="static">
            <div id="divfrom" class="layui-tab-content">
                <form class="form-horizontal m-t">
                    <div class="layui-form-item" hidden>
                        <label class="col-sm-3 layui-form-label">ID：</label>
                        <div class="col-sm-8">
                            <input id="Bd_Id" type="text" class="form-control">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="col-sm-2 layui-form-label">所属社区：</label>
                        <div class="col-sm-4">
                            <select name="temp" class="form-control" disabled="" id="Dt_Id"></select>
                        </div>
                        <label class="col-sm-2 layui-form-label">楼宇名称：</label>
                        <div class="col-sm-4">
                            <input id="Bd_Name" type="text" class="form-control" placeholder="请输入楼宇名称" autofocus="autofocus" datacol="yes" err="楼宇名称" checkexpession="NotNull" />
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="col-sm-2 layui-form-label">地上层数：</label>
                        <div class="col-sm-4">
                            <input id="Bd_Ground" type="text" class="form-control" placeholder="..." autofocus="autofocus" datacol="yes" err="地上层数" checkexpession="Num" />
                        </div>
                        <label class="col-sm-2 layui-form-label">地下层数：</label>
                        <div class="col-sm-4">
                            <input id="Bd_Underground" type="text" class="form-control" placeholder="..." autofocus="autofocus" datacol="yes" err="地下层数" checkexpession="Num" />
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="col-sm-2 layui-form-label">经度：</label>
                        <div class="col-sm-4">
                            <div class="input-group">
                                <input id="Bd_Longitude" readonly type="text" class="form-control">
                                <div class="input-group-btn">
                                    <button id="Butjingdu" class="btn btn-info" type="button">
                                        选择
                                    </button>
                                </div>
                            </div>
                        </div>
                        <label class="col-sm-2 layui-form-label">纬度：</label>
                        <div class="col-sm-4">
                            <div class="input-group">
                                <input id="Bd_Latitude" readonly type="text" class="form-control">
                                <div class="input-group-btn">
                                    <button id="Butweidu" class="btn btn-info" type="button">
                                        选择
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="col-sm-2 layui-form-label">建筑结构：</label>
                        <div class="col-sm-4">
                            <select name="temp" class="form-control" id="Bd_Structure">
                                <option value="无">--请选择--</option>
                                <option value="板房">板房</option>
                                <option value="点式">点式</option>
                            </select>
                        </div>
                        <label class="col-sm-2 layui-form-label">建筑年代：</label>
                        <div class="col-sm-4">
                            <select name="temp" class="form-control" id="Bd_Years">

                                <option value="1989年前">1989年前</option>
                                @for (var i = 1989; i <= DateTime.Now.Year; i++)
                                {
                                    <option value=@i>
                                        @i
                                    </option>
                                }
                            </select>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="col-sm-2 layui-form-label">管理员姓名：</label>
                        <div class="col-sm-4">
                            <input id="Bd_Aname" type="text" class="form-control" placeholder="..." autofocus="autofocus" datacol="yes" err="管理员姓名" checkexpession="ChineseStrOrNull">
                        </div>
                        <label class="col-sm-2 layui-form-label">管理员性别：</label>
                        <div class="col-sm-4">
                            <input type="radio" value="1" id="Bd_sex_yes" name="sex" checked>男
                            &nbsp;&nbsp;&nbsp;
                            <input type="radio" value="2" id="Bd_sex_no" name="sex">女
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="col-sm-2 layui-form-label">管理员身份证：</label>
                        <div class="col-sm-4">
                            <input id="Bd_IDNumber" type="text" class="form-control" placeholder="..." autofocus="autofocus" datacol="yes" err="管理员身份证" checkexpession="IDCardOrNull" />
                        </div>
                        <label class="col-sm-2 layui-form-label">管理员电话：</label>
                        <div class="col-sm-4">
                            <input id="Bd_Telephone" type="text" class="form-control" placeholder="..." autofocus="autofocus" datacol="yes" err="管理员电话" checkexpession="MobileOrPhoneOrNull" />
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="col-sm-2 layui-form-label">管理员照片：</label>
                        <div class="col-sm-10">
                            <div style="width:150px;height:100px;margin-top:10px;">
                                <img id="ImgFile" style="width: 80px; height: 100px;" class="upload-show0" src="" alt="" />
                                <div class="upload-box upload-img" style="float:right;"></div>
                            </div>
                            <input id="Bd_PhotoPath" type="hidden" class="form-control upload-path0" placeholder="..." autofocus="autofocus" style="width: 348px; display: inline;" readonly>
                        </div>
                    </div>

                </form>
            </div>
            <div class="hr-line-dashed"></div>
            <div class="form-group">
                <div class="col-sm-11 ">
                    <button id="btnSure" class="btn btn-info pull-right">
                        <i class="fa fa-check"></i>提交
                    </button>
                </div>
            </div>
        </div>
        @using (Html.BeginForm("Zor_Building", "Base", new RouteValueDictionary { { "Model", Model } }, FormMethod.Get))
        {
        <!-- 查询模态框 -->
        <div id="myModalSearch" hidden data-backdrop="static">
                <div id="divselectfrom" class="layui-tab-content">
                    <form class="form-horizontal m-t">
                        <div class="layui-form-item">
                            <label class="col-sm-2 layui-form-label">楼宇名称：</label>
                            <div class="col-sm-4">
                                <input id="Bd_Name" type="text" class="form-control" name="Bd_Name" value="@Model.Bd_Name">
                            </div>
                            <label class="col-sm-2 layui-form-label">地上层数：</label>
                            <div class="col-sm-4">
                                <input id="Bd_Ground" type="text" class="form-control" name="Bd_Ground" value="@Model.Bd_Ground">
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="col-sm-2 layui-form-label">地下层数：</label>
                            <div class="col-sm-4">
                                <input id="Bd_Underground" type="text" class="form-control" name="Bd_Underground" value="@Model.Bd_Underground">
                            </div>
                            <label class="col-sm-2 layui-form-label">管理员姓名：</label>
                            <div class="col-sm-4">
                                <input id="Bd_Aname" type="text" class="form-control" name="Bd_Aname" value="@Model.Bd_Aname">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="col-sm-2 layui-form-label">管理员身份证：</label>
                            <div class="col-sm-4">
                                <input id="Bd_IDNumber" type="text" class="form-control" name="Bd_IDNumber" value="@Model.Bd_IDNumber">
                            </div>
                            <label class="col-sm-2 layui-form-label">管理员电话：</label>
                            <div class="col-sm-4">
                                <input id="Bd_Telephone" type="text" class="form-control" name="Bd_Telephone" value="@Model.Bd_Telephone">
                            </div>
                        </div>

                    </form>
                    <div class="box-footer">
                        <button type="submit" class="layui-btn layui-btn-normal layui-btn-small pull-right">
                            <i class="fa fa-search"></i>查询
                        </button>
                    </div>

                </div>
            </div>
        }
        <!-- 详情模态 -->
        <div id="myModalMessage" hidden data-backdrop="static">
            <div id="divfrom" class="ibox float-e-margins">
                <div class="modal-body">
                    <form class="form-horizontal m-t">
                        <div class="layui-form-item">
                            <label class="col-sm-2 layui-form-label">所属社区：</label>
                            <div class="col-sm-4 layui-input" id="Dt_Name"></div>
                            <label class="col-sm-2 layui-form-label">楼名称：</label>
                            <div class="col-sm-4 layui-input" id="Bd_Name1"></div>
                        </div>

                        <div class="layui-form-item">
                            <label class="col-sm-2 layui-form-label">地上层数：</label>
                            <div class="col-sm-4 layui-input" id="Bd_Ground1"></div>
                            <label class="col-sm-2 layui-form-label">地下层数：</label>
                            <div class="col-sm-4 layui-input" id="Bd_Underground1"></div>
                        </div>

                        <div class="layui-form-item">
                            <label class="col-sm-2 layui-form-label">经度：</label>
                            <div class="col-sm-4 layui-input" id="Bd_Longitude1"></div>
                            <label class="col-sm-2 layui-form-label">纬度：</label>
                            <div class="col-sm-4 layui-input" id="Bd_Latitude1"></div>
                        </div>

                        <div class="layui-form-item">
                            <label class="col-sm-2 layui-form-label">建筑结构：</label>
                            <div class="col-sm-4 layui-input" id="Bd_Structure1"></div>
                            <label class="col-sm-2 layui-form-label">建筑年代：</label>
                            <div class="col-sm-4 layui-input" id="Bd_Year1"></div>
                        </div>

                        <div class="layui-form-item">
                            <label class="col-sm-2 layui-form-label">管理员姓名：</label>
                            <div class="col-sm-4 layui-input" id="Bd_Aname1"></div>
                            <label class="col-sm-2 layui-form-label">管理员性别：</label>
                            <div class="col-sm-4 layui-input" id="Bd_Sex1"></div>
                        </div>

                        <div class="layui-form-item">
                            <label class="col-sm-2 layui-form-label">管理员身份证：</label>
                            <div class="col-sm-4 layui-input" id="Bd_IDNumber1"></div>
                            <label class="col-sm-2 layui-form-label">管理员电话：</label>
                            <div class="col-sm-4 layui-input" id="Bd_Telephone1"></div>
                        </div>

                    </form>
                </div>
            </div>

        </div>
        <!-- 导出模态 -->
        <form action="/Base/ExportBuilding" enctype="multipart/form-data" method="post" id="formDownload">
            <div id="exportHtml" style="display:none;">
                <div class="eh_wrap">
                    <div class="eh_head">
                        <p style="">请选择您要导出的数据列</p>
                    </div>
                    <table width="100%" cellpadding="5" cellspacing="0">
                        <tr>
                            <td><input id="Dt_Name" type="checkbox" value="所属部门" name="chk_list" checked="checked" /><label>所属部门</label></td>
                            <td><input id="Bd_Name" type="checkbox" value="楼宇名称" name="chk_list" checked="checked" /><label>楼宇名称</label></td>
                            <td><input id="Bd_Ground" type="checkbox" value="地上层数" name="chk_list" checked="checked" /><label>地上层数</label></td>
                            <td><input id="Bd_Underground" type="checkbox" value="地下层数" name="chk_list" checked="checked" /><label>地下层数</label></td>
                        </tr>
                        <tr>
                            <td><input id="Bd_Longitude" type="checkbox" value="经度" name="chk_list" checked="checked" /><label>经度</label></td>
                            <td><input id="Bd_Latitude" type="checkbox" value="纬度" name="chk_list" checked="checked" /><label>纬度</label></td>
                            <td><input id="Bd_Aname" type="checkbox" value="管理员名称" name="chk_list" checked="checked" /><label>管理员名称</label></td>
                            <td><input id="Sex" type="checkbox" value="管理员性别" name="chk_list" checked="checked" /><label>管理员性别</label></td>
                        </tr>
                        <tr>
                            <td><input id="Bd_IDNumber" type="checkbox" value="管理员身份证号" name="chk_list" checked="checked" /><label>管理员身份证号</label></td>
                            <td><input id="Bd_Telephone" type="checkbox" value="管理员电话" name="chk_list" checked="checked" /><label>管理员电话</label></td>
                            <td><input id="Bd_CreateDate" type="checkbox" value="创建时间" name="chk_list" checked="checked" /><label>创建时间</label></td>
                        </tr>
                    </table>
                    <div class="box-footer">
                        <button type="submit" id="btnExportSure" class="btn btn-info pull-right">
                            <i class="fa fa-repeat"></i>导出
                        </button>
                        <input type="hidden" id="buildingMeg" name="buildingMeg" value="" />
                        <input type="hidden" id="where" name="where" value="" />
                    </div>
                </div>
            </div>
        </form>
    </div>
</body>

</html>
<script>

    /**
    * 获取所属部门名称
    */
    function GetDtName() {
        var html = "";
        getAjax("/Base/GetDtName", "", function (data) {
            accordionJson = eval("(" + data + ")");
            $.each(accordionJson, function (i) {
                html += "<option value='" + accordionJson[i].Dt_Id + "' >" + accordionJson[i].Dt_Name + "</option>";
            });
        });
        $("#Dt_Id").empty().append(html);
    }

    //获取选中的性别
    function SaveAdmin() {
        var radio = $('input[name = "sex"]').filter(':checked');
        radio.attr("ID", "Bd_Sex");
    }

    /**
    * 增加楼宇
    */
    $(function () {
        $("#btnAdd").click(function () {
            ClearWebControls(divfrom);
            GetDtName();
            LayerOpen('800px', '500px', '楼宇新增', $('#myModal'));
        })
    })

    /**
    * 选择经纬度
    */
    $(function () {
        $("#Butjingdu").click(function () {
          OpenWindow("/Base/SearchMap", "", 700, 500);
        })
    })
    /**
    * 选择经纬度
    */
    $(function () {
        $("#Butweidu").click(function () {
            OpenWindow("/Base/SearchMap", "", 700, 500);
        })
    })
    
    /**
    * 查询楼宇
    */
    $(function () {
        $("#btnSearch").click(function () {
            ClearWebControls(divfrom);
            LayerOpen('800px', '270px', '楼宇查询', $('#myModalSearch'));
        })
    })

    /**
    * 修改楼宇
    */
    $(function () {
        $("#btnUpdate").click(function () {
            var checkId = CheckboxValueIDs();
            var Dt_Id = getTableCell(2);    //获取选中行的部门名称
            var Bd_Name = getTableCell(5);    //获取选中行的楼宇名称
            var Bd_Ground = getTableCell(6);    //获取选中行的地上层数
            var Bd_Underground = getTableCell(7);    //获取选中行的地下层数
            var Bd_Longitude = getTableCell(8);    //获取选中行的经度
            var Bd_Latitude = getTableCell(9);    //获取选中行的纬度
            var Bd_Structure = getTableCell(3);    //获取选中行的建筑结构
            var Bd_Year = getTableCell(4);    //获取选中行的建筑年代
            var Bd_Aname = getTableCell(10);    //获取选中行的管理员名称
            var Bd_Sex = getTableCell(11);    //获取选中行的管理员性别
            var Bd_IDNumber = getTableCell(12);    //获取选中行的管理员身份证号
            var Bd_Telephone = getTableCell(13);    //获取选中行的管理员电话
            $("#lbltitle").text("修改楼宇");
            $("#Bd_Id").attr("disabled", "disabled");
            if (checkId.length == 0) {
                layer.msg("请选择要修改的楼宇！");
                return;
            }
            if (checkId.length > 1) {
                layer.msg("仅可选择一行信息修改！");
                return;
            }
            GetDtName();
            $("#Bd_Id").val(checkId[0]);
            $("#Dt_Id").val(Dt_Id);
            $("#Bd_Name").val(Bd_Name);
            $("#Bd_Ground").val(Bd_Ground);
            $("#Bd_Underground").val(Bd_Underground);
            $("#Bd_Longitude").val(Bd_Longitude);
            $("#Bd_Latitude").val(Bd_Latitude);
            $("#Bd_Structure").val(Bd_Structure);
            $("#Bd_Years").val(Bd_Year);
            $("#Bd_Aname").val(Bd_Aname);
            $("#Bd_Sex").val(Bd_Sex);
            $("#Bd_IDNumber").val(Bd_IDNumber);
            $("#Bd_Telephone").val(Bd_Telephone);
            LayerOpen('800px', '500px', '楼宇修改', $('#myModal'));
        })
    })
    /**
     * 楼宇详情
     */
    $(function () {
        $("#btnMessage").click(function () {
            var checkId = CheckboxValueIDs();
            var Dt_Name = getTableCell(16);    //获取选中行的部门名称
            var Bd_Name1 = getTableCell(5);    //获取选中行的楼宇名称
            var Bd_Ground1 = getTableCell(6);    //获取选中行的地上层数
            var Bd_Underground1 = getTableCell(7);    //获取选中行的地下层数
            var Bd_Longitude1 = getTableCell(8);    //获取选中行的经度
            var Bd_Latitude1 = getTableCell(9);    //获取选中行的纬度
            var Bd_Structure1 = getTableCell(3);    //获取选中行的建筑结构
            var Bd_Year1 = getTableCell(4);    //获取选中行的建筑年代
            var Bd_Aname1 = getTableCell(10);    //获取选中行的管理员名称
            var Bd_Sex1 = getTableCell(11);    //获取选中行的管理员性别
            var Bd_IDNumber1 = getTableCell(12);    //获取选中行的管理员身份证号
            var Bd_Telephone1 = getTableCell(13);    //获取选中行的管理员电话
            $("#lbltitle").text("修改楼宇");
            $("#Bd_Id").attr("disabled", "disabled");
            if (checkId.length == 0) {
                layer.msg("请选择要查看的楼宇！");
                $("#myModalMessage").attr("ID", "test");
                return;
            }
            if (checkId.length > 1) {
                layer.msg("仅可选择一栋楼宇查看！");
                $("#myModalMessage").attr("ID", "test");
                return;
            }
            LayerOpen('820px', '360px', '楼宇详情', $('#myModalMessage'));

            $("#test").attr("ID", "myModalMessage");
            $("#Bd_Id").html(checkId[0]);
            $("#Dt_Name").html(Dt_Name);
            $("#Bd_Name1").html(Bd_Name1);
            $("#Bd_Ground1").html(Bd_Ground1);
            $("#Bd_Underground1").html(Bd_Underground1);
            $("#Bd_Longitude1").html(Bd_Longitude1);
            $("#Bd_Latitude1").html(Bd_Latitude1);
            $("#Bd_Structure1").html(Bd_Structure1);
            $("#Bd_Year1").html(Bd_Year1);
            $("#Bd_Aname1").html(Bd_Aname1);
            $("#Bd_Sex1").html(Bd_Sex1);
            $("#Bd_IDNumber1").html(Bd_IDNumber1);
            $("#Bd_Telephone1").html(Bd_Telephone1);
        })
    })

    /**
    * 删除楼宇
    */
    $(function () {
        $("#btnDelete").click(function () {
            var checkId = CheckboxValueIDs();
            if (checkId.length == 0) {
                layer.msg("请选择要删除的楼宇！");                                                             //未选中任何行
                return;
            }
            else {
                layer.confirm("确定要删除吗?", { icon: 2, btn: ['确定', '取消'] }, function () {
                    ZorPostSimpleData("/Base/DeleteBuilding", JSON.stringify({ 'id': checkId }), function (data) { //获取数据(带参数)
                        if (data.AnswerType == 1)
                            Replace();
                        layer.msg(data.AnswerMeg);
                    })
                })
            }
        })
    })

    /**
    * 刷新
    **/
    $(function () {
        $("#btnReplace").click(function () {
            Replace();
        })
    })

    /**
    * 保存
    */
    $(function () {
        $("#btnSure").click(function () {
            SaveAdmin();
            if (!CheckDataValid('.form-horizontal')) {
                return false;
            }
            if ($("#Bd_Ground").val() <= 0) {
                layer.msg("地上层数必须大于0！");
                return;
            }           
            if ($("#Bd_Longitude").val() <= 0) {
                layer.msg("经度层数必须大于0！");
                return;
            }
            if ($("#Bd_Latitude").val() <= 0) {
                layer.msg("纬度层数必须大于0！");
                return;
            }
            var JsData = GetWebControls(divfrom);
            ZorPostSimpleData("/Base/AddBuilding", JSON.stringify({ "building": JsData }), function (data) {
                layer.msg(data.AnswerMeg, function () {
                    layer.closeAll();
                    Replace();
                });
            });
        })
    })

    ///**
    //* 全选
    //*/
    //$(function () {
    //    $("#cbkCheckAll").click(function () {
    //        if (this.checked) {
    //            $("input[name='chk']").prop('checked', true);
    //        } else {
    //            $("input[name='chk']").prop('checked', false);
    //        }
    //    })
    //})

    /*导出*/
    $("#btnExport").click(function () {
        layer.open({
            type: 1,
            title: '导出提示',
            shade: false,
            skin: 'layui-layer-rim',
            area: ['620px', '280px'], //宽高
            content: $('#exportHtml')
        });
    });
    /*导出交互*/
    $("#btnExportSure").click(function () {
        var arr = new Array();
        $("[name='chk_list']").each(function () {
            if ($(this).is(":checked")) {
                arr.push($(this).attr("id") + "|" + $(this).val());
            }
        });
        $("#buildingMeg").val(arr);
        document.getElementById('formDownload').submit();
        layer.closeAll();
    });



    $(function () {
        //初始化上传控件
        $(".upload-img").InitUploader({
            sendurl: "../tools/UploadServer.ashx", swf: "../Content/Scripts/webuploader/uploader.swf", thumbnail: true, filetypes: "jpg,png,gif", actionflag: "UpLoadImg"
        });
    })
</script>
